import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from config import URL


def web_driver(url=URL):
    """
    :param url: 默认为URL,浏览器地址
    :return: 浏览器对象
    """
    # Chrome浏览器:
    path = r"D:\Programs\Python\Python313\chromedriver.exe"
    ser = Service(executable_path=path)
    driver = webdriver.Chrome(service=ser)
    time.sleep(3)
    # 3.打开Web页面
    driver.get(url)
    driver.maximize_window()
    return  driver

def driver_quit(driver):
    """
    :param driver: 浏览器对象
    :return: None
    """
    time.sleep(3)
    driver.quit()

if __name__ == '__main__':
    driver = web_driver()
    driver_quit(driver)